<template>
	<view>
		<scroll-view scroll-y="true">
			<view>
				<view class="" v-for="d in list">
					<uni-card :title="d.user.info.nickname || d.user.uwer.username">
						<view class="">
							<view class="">
								{{d.title}}
							</view>
							<view class="message-info">
								<view class="">
									{{Api.formatDate(d.lastupdate)}}
								</view>
								<view class="">
									赞{{d.hits}}
								</view>
							</view>

						</view>
					</uni-card>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script setup>
	import {
		ref,
		onMounted
	} from 'vue';

	import {
		Api
	} from '../../js/api.js';

	const page = ref({
		pageSize: 10,
		pageNumber: 1
	})
	const order = ref(1)
	const info = ref('')
	const list = ref([])

	const query = () => {
		Api.get(`/message/${page.value.pageSize}/${page.value.pageNumber}/${order.value}`, {
			info: info.value
		}, (data) => {
			if (data.success) {
				page.value = data.data.pageBean
				list.value = data.data.list
				return
			}
			uni.showToast({
				title: data.message,
				icon: 'error'
			})
		})
	}


	onMounted(() => {
		query()
	})
</script>

<style>
	.message-info {
		display: flex;
		justify-content: space-between;
		padding: 0.5rem 0px;
	}
</style>